package f;

import c.j.a.c.y.a.i;
import f.f0.c;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nullable;

/* compiled from: Request */
public final class y {
    public final r a;
    public final String b;
    public final q c;
    @Nullable
    public final z d;
    public final Map<Class<?>, Object> e;
    @Nullable
    public volatile c f;

    /* compiled from: Request */
    public static class a {
        @Nullable
        public r a;
        public String b;
        public f.q.a c;
        @Nullable
        public z d;
        public Map<Class<?>, Object> e;

        public a() {
            this.e = Collections.emptyMap();
            this.b = "GET";
            this.c = new f.q.a();
        }

        public a a(String str, String str2) {
            f.q.a aVar = this.c;
            Objects.requireNonNull(aVar);
            q.a(str);
            q.b(str2, str);
            aVar.a.add(str);
            aVar.a.add(str2.trim());
            return this;
        }

        public y b() {
            if (this.a != null) {
                return new y(this);
            }
            throw new IllegalStateException("url == null");
        }

        public a c(String str, String str2) {
            f.q.a aVar = this.c;
            Objects.requireNonNull(aVar);
            q.a(str);
            q.b(str2, str);
            aVar.b(str);
            aVar.a.add(str);
            aVar.a.add(str2.trim());
            return this;
        }

        public a d(String str, @Nullable z zVar) {
            Objects.requireNonNull(str, "method == null");
            if (str.length() != 0) {
                String str2 = "method ";
                if (zVar == null || i.E(str)) {
                    if (zVar == null) {
                        Object obj = (str.equals("POST") || str.equals("PUT") || str.equals("PATCH") || str.equals("PROPPATCH") || str.equals("REPORT")) ? 1 : null;
                        if (obj != null) {
                            throw new IllegalArgumentException(c.b.a.a.a.E(str2, str, " must have a request body."));
                        }
                    }
                    this.b = str;
                    this.d = zVar;
                    return this;
                }
                throw new IllegalArgumentException(c.b.a.a.a.E(str2, str, " must not have a request body."));
            }
            throw new IllegalArgumentException("method.length() == 0");
        }

        public a e(String str) {
            Objects.requireNonNull(str, "url == null");
            StringBuilder g;
            if (str.regionMatches(true, 0, "ws:", 0, 3)) {
                g = c.b.a.a.a.g("http:");
                g.append(str.substring(3));
                str = g.toString();
            } else {
                if (str.regionMatches(true, 0, "wss:", 0, 4)) {
                    g = c.b.a.a.a.g("https:");
                    g.append(str.substring(4));
                    str = g.toString();
                }
            }
            f.r.a aVar = new f.r.a();
            aVar.d(null, str);
            f(aVar.b());
            return this;
        }

        public a f(r rVar) {
            Objects.requireNonNull(rVar, "url == null");
            this.a = rVar;
            return this;
        }

        public a(y yVar) {
            Map emptyMap;
            this.e = Collections.emptyMap();
            this.a = yVar.a;
            this.b = yVar.b;
            this.d = yVar.d;
            if (yVar.e.isEmpty()) {
                emptyMap = Collections.emptyMap();
            } else {
                emptyMap = new LinkedHashMap(yVar.e);
            }
            this.e = emptyMap;
            this.c = yVar.c.e();
        }
    }

    public y(a aVar) {
        this.a = aVar.a;
        this.b = aVar.b;
        this.c = new q(aVar.c);
        this.d = aVar.d;
        Map map = aVar.e;
        byte[] bArr = c.a;
        if (map.isEmpty()) {
            map = Collections.emptyMap();
        } else {
            map = Collections.unmodifiableMap(new LinkedHashMap(map));
        }
        this.e = map;
    }

    public c a() {
        c cVar = this.f;
        if (cVar != null) {
            return cVar;
        }
        cVar = c.a(this.c);
        this.f = cVar;
        return cVar;
    }

    public String toString() {
        StringBuilder g = c.b.a.a.a.g("Request{method=");
        g.append(this.b);
        g.append(", url=");
        g.append(this.a);
        g.append(", tags=");
        g.append(this.e);
        g.append('}');
        return g.toString();
    }
}
